home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- ///////////////////////////////////////////////////
- // OkScrolledList.h
- ///////////////////////////////////////////////////
- #ifndef OKSCROLLEDLIST_H
- #define OKSCROLLEDLIST_H
-
- #include "OkComponent.h"
-
- #include "OkStrArray.h"
-
- #include <Vk/VkListSearch.h>
-
- #include <Xm/List.h>
-
-
- class OkScrolledList : public OkComponent {
-
- private:
- CALLBACKSTUB( OkScrolledList, browseSelection );
- CALLBACKSTUB( OkScrolledList, defaultAction );
- CALLBACKSTUB( OkScrolledList, extendedSelection );
- CALLBACKSTUB( OkScrolledList, multipleSelection );
- CALLBACKSTUB( OkScrolledList, singleSelection );
-
- void build( Widget parent, const char* name, Widget srchText=NULL,
- ArgList list=NULL, Cardinal count=0 );
-
- // Search stuff.
- VkListSearch *_listSearch;
- Widget _searchText;
-
- protected:
- // Callbacks. Derived class will override these funcs to do
- // something useful.
- virtual void browseSelection() {}
- virtual void defaultAction() {}
- virtual void extendedSelection() {}
- virtual void multipleSelection() {}
- virtual void singleSelection() {}
-
- VkListSearch* listSearch() { return _listSearch; }
-
- public:
- OkScrolledList( const char* name, Widget parent, Widget srchText=NULL,
- ArgList list=NULL, Cardinal count=0 );
- OkScrolledList( const char* name, Widget parent, OkStrArray& items,
- Widget srchText=NULL );
- virtual ~OkScrolledList() { delete _listSearch; }
- virtual const char* className() { return "OkScrolledList"; }
-
- int itemCount() const;
- int selectedItemCount();
-
-
- // Add Items.
- void addItem( XmString item, int pos=0, Boolean unselected=True );
- void addItem( const char* item, int pos=0, Boolean unselected=True )
- { addItem( (XmString) OkCompoundString( item ), pos, unselected ); }
- void addItems( XmString* items, int itemCount,
- int pos=0, Boolean unselected=True );
- void addItems( const char** items, int itemCount,
- int pos=0, Boolean unselected=True );
-
- void addItems( OkStrArray& items, int pos=0, Boolean unselected=True );
-
-
- // Delete items.
- void deleteAllItems() { XmListDeleteAllItems( _baseWidget ); }
-
- void deleteItem( XmString item ) { XmListDeleteItem( _baseWidget, item ); }
- void deleteItem( const char* item )
- { deleteItem( (XmString) OkCompoundString( item ) ); }
- void deleteItem( int pos ) { deleteItems( pos ); }
-
- void deleteItems( XmString* items, int itemCount )
- { XmListDeleteItems( _baseWidget, items, itemCount ); }
- void deleteItems( const char** items, int itemCount );
- void deleteItems( OkStrArray& items );
- void deleteItems( int pos, int itemCount=1 )
- { XmListDeleteItemsPos( _baseWidget, itemCount, pos ); }
- void deleteItems( int* posList, int itemCount )
- { XmListDeletePositions( _baseWidget, posList, itemCount ); }
-
- void deleteLastItem() { deleteItem( 0 ); }
-
-
- // Replace items.
- void replaceItem( XmString item, int atPos, Boolean unselected=TRUE );
- void replaceItem( const char* item, int atPos, Boolean unselected=TRUE )
- { replaceItem( XmString( OkCompoundString( item ) ), atPos, unselected ); }
- void replaceItems( OkStrArray& items, int atPos, Boolean unselected=TRUE );
-
-
- // Select items.
- void selectItem( XmString item, Boolean notify=True )
- { XmListSelectItem( _baseWidget, item, notify ); }
- void selectItem( const char* item, Boolean notify=True )
- { selectItem( (XmString) OkCompoundString( item ), notify ); }
- void selectItem( unsigned pos, Boolean notify=True )
- { XmListSelectPos( _baseWidget, pos, notify ); }
-
-
- // Deselect items.
- void deselectAllItems()
- { XmListDeselectAllItems( _baseWidget ); }
-
- void deselectItem( XmString item )
- { XmListDeselectItem( _baseWidget, item ); }
- void deselectItem( const char* item )
- { deselectItem( (XmString) OkCompoundString( item ) ); }
- void deselectItem( int pos )
- { XmListDeselectPos( _baseWidget, pos ); }
-
-
- // Get selected items.
- int getSelectedItem();
- int getSelectedItems( int **posList ); // Caller needs to free posList.
- int getSelectedItems( OkStrArray* itemList );
-
-
- // Miscelaneous.
- unsigned char selectionPolicy();
- unsigned char selectionPolicy( unsigned char policy );
-
- void firstVisibleItem( XmString item ) { XmListSetItem( _baseWidget, item ); }
- void firstVisibleItem( unsigned pos ) { XmListSetPos( _baseWidget, pos ); }
-
- void lastVisibleItem( XmString item )
- { XmListSetBottomItem( _baseWidget, item ); }
- void lastVisibleItem( int pos )
- { XmListSetBottomPos( _baseWidget, pos ); }
-
- int getKbdItemPos() { return XmListGetKbdItemPos( _baseWidget ); }
-
- unsigned findItem( XmString item )
- { return XmListItemPos( _baseWidget, item ); }
-
- Boolean isItemSelected( unsigned pos )
- { return XmListPosSelected( _baseWidget, pos ); }
-
- const char* operator[]( unsigned int ) const;
- const char* item( unsigned int i ) const { return (*this)[ i ]; }
-
- };
-
- #endif
-